<template>
	<view class="every-share">
		<view class="waterfall-item shop" v-for="(item,index) in list" :key='index' 
		@click="goPage('/pages/index/every-share-detail/every-share-detail?id='+item.id)">
			<view v-if="!item.ad">
				<image :src="item.imgurl" mode="widthFix"></image>
				<view class="waterfall-item-content">
					<view class="name fex3">{{item.word}}</view>
					<view class="seller_name" v-if="item.seller_name">
						<text class="iconfont icon-shop"></text>
						<text class="fex1">{{item.seller_name}}</text>
					</view>
					<view class="prices">
						<text>{{formatDate(item.create_time*1000)}}</text>
						<text>--{{item.wordfrom}}</text>
					</view>
				</view>
			</view>
			<view v-else>
				<!-- #ifdef APP-PLUS -->
				<news-flow :type="item.ad"></news-flow>
				<!-- #endif -->
				<!-- #ifdef H5 -->
				<news-flow class="there-H5" v-if="item.ad==1||item.ad==3" :type="6"></news-flow>
				<news-flow class="big-H5" v-else :type="7"></news-flow>
				<!-- #endif -->
			</view>
		</view>
		<block-loading :status="status" :len="list.length"></block-loading>
	</view>
</template>

<script>
	 import {getShareLists} from '@/api/activity.js'
	 import {formatDate} from '@/utils/util.js'
	 export default{
		 name:"every-share",
		 data(){
			 return{
				 list:[],
				 status: "loading",
				 page: 1,
			 }
		 },
		 onLoad() {
		 	this.getLoad()
		 },
		 //上拉加载
		 onReachBottom() {
		 	this.getLoad()
		 },
		 //下拉刷新
		 onPullDownRefresh() {
		 	this.status = "nomal"
		 	this.list = [];
		 	this.page = 1;
		 	this.getLoad()
		 },
		 methods:{
			 goPage(url){
				uni.navigateTo({
					url:url
				}) 
			 },
			 formatDate(val){
				 return formatDate(val)
			 },
			 async getLoad(){
				let res = await getShareLists({page:this.page,size:20});
				if(res.code === 1){
					uni.stopPullDownRefresh();
					if(this.page===1&&res.data.length === 0){
						this.status = "nodata"
						return
					}
					if(this.page===1&&res.data.length > 0 && res.data.length < 20){
						this.status = "nomore"
					}
					if(res.data.length === 0){
						this.status = "nomore"
						return;
					}
					this.page++;
					
					res.data.splice(0, 0, {ad:1});
					res.data.splice(5, 0, {ad:2});
					res.data.splice(10, 0, {ad:3});
					res.data.splice(14, 0, {ad:4}); 
					res.data.splice(18, 0, {ad:5});
					this.list = this.list.concat(res.data);
				}
			 }
		 }
	 }
</script>

<style scoped lang="less" src="./every-share.less">
</style>
